//
//  MenuListCell.m
//  Koina
//
//  Created by welldone on 13-9-7.
//  Copyright (c) 2013年 net.koina. All rights reserved.
//

#import "MenuListCell.h"
#import "Tools.h"
#import "config.h"

#define imgW  13
#define imgH  13

@interface MenuListCell ()

@end

@implementation MenuListCell
@synthesize imgWithButton;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        imgWithButton = [UIButton buttonWithType:UIButtonTypeCustom];
        imgWithButton.titleLabel.shadowColor = [UIColor colorWithRed:(float)0x00/(float)0xff green:(float)0x00/(float)0xff blue:(float)0x00/(float)0xff alpha:(float)0x59/(float)0xff];
//        imgWithButton.titleLabel.shadowOffset = CGSizeMake(0, -1.0);
        [imgWithButton.titleLabel setFont:[UIFont systemFontOfSize:TextFont]];
        [imgWithButton setBackgroundImage:[Tools getImgByColor:UIColorFromRGB(0x515151)] forState:UIControlStateNormal];
        
        [imgWithButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [imgWithButton setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
        
        [imgWithButton setImage:[UIImage imageNamed:@"icon29"] forState:UIControlStateNormal];
        
//        [imgWithButton setTintAdjustmentMode:<#(UIViewTintAdjustmentMode)#>]
        [imgWithButton setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
        [imgWithButton setContentVerticalAlignment:UIControlContentVerticalAlignmentCenter];
        [imgWithButton setFrame:CGRectMake(0,0,self.contentView.frame.size.width,self.contentView.frame.size.height - 1)];
        [imgWithButton setUserInteractionEnabled:NO];
        
        UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(3, self.contentView.frame.size.height- 1,self.contentView.frame.size.width - 2*3 , 1)];
        [lineView setBackgroundColor:UIColorFromRGB(0x333333)];
        [self.contentView addSubview:lineView];
        
        [self.contentView addSubview:imgWithButton];
  
    }
    return self;
}


-(void)setTitle:(NSString*)title{
    
    [imgWithButton setTitle:title forState:UIControlStateNormal];
    [imgWithButton setTitle:title forState:UIControlStateHighlighted];
}



-(void)setIsCur:(Boolean)cur{


    if (true) {
        
//<<<<<<< .mine
////        CGSize labSize = [imgWithButton.titleLabel.text sizeWithFont:imgWithButton.titleLabel.font];
//        
//    
//=======
//
//>>>>>>> .r268
        [[self imgWithButton] setImage:[UIImage imageNamed:@"icon29"] forState:UIControlStateNormal];
        
        [[self imgWithButton] setImage:[UIImage imageNamed:@"icon29"] forState:UIControlStateHighlighted];
        
        [self.imgWithButton setContentEdgeInsets:UIEdgeInsetsMake(0, 13, 0, 0)];
        [[self imgWithButton]setImageEdgeInsets:UIEdgeInsetsMake(0, -5, 0, 0)];
//        [[self imgWithButton]setImageEdgeInsets:UIEdgeInsetsMake(0, labSize.width+40, 0, 0)];
//        
//        [self.imgWithButton setTitleEdgeInsets:UIEdgeInsetsMake(0, 20, 0, 0)];
        
    }
//    else{
//        
//        [[self imgWithButton] setImage:nil forState:UIControlStateNormal];
//        [[self imgWithButton] setImage:nil forState:UIControlStateHighlighted];
//        
//        [self.imgWithButton setTitleEdgeInsets:UIEdgeInsetsMake(0, 20, 0, 0)];
//        [[self imgWithButton]setImageEdgeInsets:UIEdgeInsetsZero];
//    }
    
}




//- (CGRect)titleRectForContentRect:(CGRect)contentRect;
//{
//    
//    CGSize labSize = [imgWithButton.titleLabel.text sizeWithFont:imgWithButton.titleLabel.font];
//    CGFloat titleX = 5 *2 + imgW;
//    CGFloat titleY = (contentRect.size.height - labSize.height)/2.0;
//    return CGRectMake(titleX, titleY, labSize.width, labSize.height);
//    
//}
//- (CGRect)imageRectForContentRect:(CGRect)contentRect;
//{
//    CGFloat imgX = contentRect.origin.x + 5;
//    CGFloat imgY = (contentRect.size.height - imgH)/2.0;
//    return CGRectMake(imgX, imgY, imgW, imgH);
//    
//}
-(void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated{
    [super setHighlighted:highlighted animated:animated];
    
    [self.imgWithButton setHighlighted:highlighted];

}



@end
